package com.example.mapper;

import com.example.dto.StuFindDto;
import com.example.pojo.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Insert("insert into user (name, dormitory_id,category_name,create_time, update_time) values (#{name},#{dormitoryId},#{categoryName},#{createTime},#{updateTime})")
    void addUser(User user);

    @Select("select * from user where name = #{name}")
    User findUser(String name);

    @Update("update user set name = #{name},dormitory_id = #{dormitoryId},category_name = #{categoryName} where id = #{id}")
    void updateUser(User user);

    @Select("select * from user where id = #{id}")
    User getUserInfo(Integer id);

    @Delete("delete from user where id = #{id}")
    void deleteUser(Integer id);

    Page<User> PageList(@Param("name") String name,@Param("dormitoryId") String dormitoryId,@Param("categoryName")String categoryName);

    @Update("update user set dormitory_id = #{dormitoryId},category_name = #{categoryName} where name = #{name}")
    void addDormitory(@Param("name") String name,@Param("dormitoryId") String dormitoryId,@Param("categoryName")String categoryName);



    User findStu(StuFindDto stuFindDto);

    @Select("select * from user where dormitory_id = #{dormitoryId} and category_name = #{categoryName}")
    Page<User> findPeo(@Param("dormitoryId") String dormitoryId,@Param("categoryName") String categoryName);

    @Select("select * from user where name = #{stuName}")
    User findByStuName(String stuName);
}
